/*=================================================================================
 * Class Euler:	The main solver
 *				Intialization -> Compute and Update -> Output
 *=================================================================================*/

#ifndef EULER_H
#define EULER_H

/*---------------------------------------------------------------------------------
 * Standard C++ library headers
 *---------------------------------------------------------------------------------*/

#include <fstream>
#include <iostream>

/*---------------------------------------------------------------------------------
 * Local headers
 *---------------------------------------------------------------------------------*/

#include "Array.h"
#include "Mesh.h"
#include "Flowfield.h"
#include "Reaction.h"

class Euler
{
private:
	char ctrlfile[100] = "./input/ctrl.txt"; /* Ctrl file */
	char meshFile[100];						 /* Grid file */
	char inputFile[100];					 /* Input file */
	char Reaction_Model[100];				 /* Reaction model file */
	char thermoFile[100];					 /* Thermo data file */
	int Reaction_Sch;						 /* The reaction scheme */
	int type;								 /* The type of selected reaction scheme */
	int Diff_Sch;							 /* The difference scheme */
	int TimeAdv_Sch;						 /* The time advance scheme */
	double Final_Time;						 /* Final time */
	double cfl;								 /* The cfl number */
	double dt;								 /* The fixed time step (if necessary) */
	int count;								 /* The number of output files */
	int iteration;							 /* Iteration steps */
	int myid,numprocs;                        /*OPENMPI Information*/
	
	Mesh Mymesh;							 /* Class Mesh -> Object Mymesh */
	Flowfield TwoDim;						 /* Class Flowfield -> Object TwoDim */
	Reaction React;							 /* Class Reaction -> Object React */

	/* Read the file */
	void FileRead();

public:
	/* Constructor */
	Euler();

	/* Solve the Euler equation and update the flow field */
	void Computing(int count);

	/* Solve the reaction term by trapezoid formula */
	void Trapezoid(int type);

	/* Solve the reaction term by IMEX method */
	void IMEX();

	/* Solve the reaction term by Cantera or DNN method */
	void DNN(int type);

	/* Output the result in file */
	void Output(int num);
	void Output_MPI(int num,int id);

	// MPI adds below functions zxk 2024/1/1
	void OutputWtime(double* val);

	/* Destructor */
	~Euler() { ; };
};
#endif